//package server;
//
//import java.io.File;
//import java.io.IOException;
//import java.lang.reflect.InvocationTargetException;
//import java.lang.reflect.Method;
//import java.net.MalformedURLException;
//import java.net.URL;
//import java.net.URLClassLoader;
//
///**
// * @author sxnan
// * @className LagouServlet
// * @description TODO
// * @date 2020/7/21
// */
//public class LagouServlet extends HttpServlet{
//    @Override
//    public void doGet(Request request, Response response) {
//        String content = "<h1>LagouServlet Get</h1>";
//        try {
//            response.output(HttpProtocolUtil.getHeaderStr200(content.getBytes().length)+content);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Override
//    public void doPost(Request request, Response response) {
//        String content = "<h1>LagouServlet Post</h1>";
//        try {
//            response.output(HttpProtocolUtil.getHeaderStr200(content.getBytes().length)+content);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Override
//    public void init() throws Exception {
//
//    }
//
//    @Override
//    public void destory() throws Exception {
//
//    }
//
//    public static void main(String[] args) throws ClassNotFoundException, MalformedURLException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
////        File clazzPath1 = new File("/Users/webapps");
////        String className1 = clazzPath1.getAbsolutePath();
////        int clazzPathLen = clazzPath1.getAbsolutePath().length() + 1;
////        File clazzPath = new File("/Users/webapps/demo02/LagouServlet.java");
////        String className = clazzPath.getAbsolutePath();
////        className = className.substring(clazzPathLen, className.length() - 5);
////        //将/替换成. 得到全路径类名
////        className = className.replace(File.separatorChar, '.');
////        // 加载Class类
////        Class<?> aClass = Class.forName(className);
////        System.out.println(className);
//
//        //类根路径
////        ClassLoader classLoader = new URLClassLoader();
////                new ClassLoader(new String[]{"D:\\Cheiron\\Test\\bin"});
////        Class<?> cl = classLoader.loadClass("org.apache.commons.lang.StringUtils");//类名
//
//        ClassLoader cl = new URLClassLoader(new URL[]{new File("/Users/webapps/demo01").toURL()});
//        // Load in the class; Test2.class should be located in
//        // the directory file:/D：\test\zy\
//        Class cls = cl.loadClass("server.LagouServlet");
//        Object o = cls.newInstance();
//        Method method = cls.getMethod("doGet", Request.class, Response.class);//类的方法bai
//        System.out.println(method.getName());//打印方法名
//         method.invoke(o, null, null);//调用方法
//    }
//}